#set(title="找回密码")
#@WeuiLayout()
#define cssStyle()
<style>
	#authBox {height: 100%;background-image: url('#(res_path)/image/member_login_bg.jpg');color: #F3F3F3}
	#authBox .iconfont {color: #999;font-size: 21px}
	#authBox .weui-cells_form {margin: 0 15px;border-radius:5px;}
	#authBox .weui-cells_form .weui-cell__hd {width: 30px}
	#authBox .weui-cells_form .weui-input {font-size: 14px;color: #333}
	#authBox .weui-msg__opr-area {padding: 5px 0px}
	#authBox .weui-msg__opr-area .weui-btn {margin-bottom: 20px}
	#authBox .weui-vcode-btn {height: 30px;line-height: 30px}
</style>
#end
#define content()
<div id="authBox">
	<form onsubmit="return ajaxSubmit(this)">
		<div class="weui-msg" style="max-width: 350px;margin: 0 auto;">
		  <div class="weui-msg__text-area">
		    <h2 class="weui-msg__title">#(param("AUTH_MEMBER_NAME"))</h2>
		    <p class="weui-msg__desc">请填写以下内容找回密码</a></p>
		  </div>
		  #set(mode=param("AUTH_MEMBER_REGISTER_TYPE"))
			<div class="weui-cells weui-cells_form">
		  	#if(mode=="PHONE")
				  <div class="weui-cell">
				    <div class="weui-cell__hd"><i class="iconfont icon-shoujihao"></i></div>
				    <div class="weui-cell__bd">
				      <input class="weui-input" type="text" name="to" placeholder="请输入手机号">
				    </div>
				  </div>
				  <div class="weui-cell">
				    <div class="weui-cell__hd"><i class="iconfont icon-duanxinyanzhengma"></i></div>
				    <div class="weui-cell__bd">
				      <input class="weui-input" type="text" name="auth" placeholder="短信验证码">
				    </div>
				    <div class="weui-cell__ft">
				      <button type="button" class="weui-vcode-btn" onclick="sendMessage(this)">获取验证码</button>
				    </div>
				  </div>
			  #end
			  <div class="weui-cell">
			    <div class="weui-cell__hd"><i class="iconfont icon-mima"></i></div>
			    <div class="weui-cell__bd">
			      <input class="weui-input" type="password" name="password" placeholder="设置新密码">
			    </div>
			  </div>
			</div>
		  <div class="weui-msg__opr-area">
		    <div class="weui-btn-area">
		      <button class="weui-btn weui-btn_primary">设置新密码</button>
			    <div class="weui-flex">
				  	<div class="weui-flex__item" style="text-align: left;">
				  		<a style="color:#FFF" href="#(res_path)#(PRE_PATH)/auth/login?redirect=#(redirect)">已有账户</a>
				  	</div>
			    	#if(param("AUTH_MEMBER_REGISTER_ONOFF")=="ON")
				  	<div class="weui-flex__item" style="text-align: right;">
				  		<a style="color:#FFF" href="#(res_path)#(PRE_PATH)/auth/register?redirect=#(redirect)">注册会员</a>
				  	</div>
				  	#end
					</div>
		    </div>
		  </div>
		  <div class="weui-msg__extra-area">
		      <p class="weui-footer__text">Copyright © 2017 #(param("AUTH_MEMBER_NAME"))</p>
		    </div>
		  </div>
		</div>
	</form>
</div>
#end
#define jsFunction()
<script>
	function ajaxSubmit(obj){
		$.ajax({
			type:"POST",
			url:"#(res_path)#(PRE_PATH)/auth/doForget",
			data:$(obj).serialize(),
			dataType:"json",
			success:function(data){
				if(data.result=="success"){
					layer.alert("设置新密码成功！",{icon:1},function(){
						location.href="#(res_path)#(PRE_PATH)/auth/login?redirect=#(redirect)";
					});
				}else {
					layer.alert(data.message,{icon:2});
				}
			}
		});
		return false;
	}
	var sms = 0;
	function sendMessage(obj){
		if(sms>0) return;
		sms = 60;
		$.ajax({
			type:"POST",
			url:"#(res_path)#(PRE_PATH)/common/push/captcha",
			data:{to:$("input[name='to']").val(),auth_type:"#(mode)FORGET"},
			dataType:"json",
			async:false,
			success:function(data){
				if(data.result=="success"){
					layer.msg("发送成功，请注意查收！");
					daojishi(obj);
				}else {
					sms = 0;
					layer.alert(data.message,{icon:2});
				}
			}
		});
	}
	function daojishi(obj){
		setTimeout(function(){
			if(sms>=0){
				$(obj).html("再次发送("+sms+")");
				sms = sms -1;
				daojishi(obj);
			}else {
				$(obj).html("再次发送");
			}
		},1000);
	}
</script>
#end